/*
Runs event-study regressions presented in section 5 and supplement.
*/

set more off

clear all

set scheme s1mono

use "$data/incFinalMonthlyTehsil"

//Labels for figures
label variable totCas "Casualties"
label variable incidents "Attacks"
label variable trtXnwa "treat\(\cdot\)nwa"
label variable my10 "0"

drop if dist=="swa" //Drop SWA observations

xtset tehsiln monyr

//Event-study version of baseline regression for incidents
xtreg incidents $events1 $tmFE, fe cluster(tehsiln)
eststo EV1_inc6_est1
test $events1_a

//save F-Test p-value
local pval = round(`r(p)',0.001)
texdoc init "$tex/parallel_inc_p.tex", replace force
tex 0`pval'
texdoc close

//Plot event-study coefficents and output Figure 7a from main text
coefplot (EV1_inc6_est1, offset(0) recast(line) lwidth(*2) ciopts(recast(rline) lp(dash))), keep($events1 my10)  rescale(my10 = 0) order($events1_a my10 $events1_b) vertical xline(10) yline(0) ytitle("") xtitle("") xlabels(, labsize(medium)) ylabels(,angle(0) labsize(medium))
gr export "$figures/EV1_inc6.pdf", replace


//Event-study version of baseline regression for casualties
xtreg totCas $events1 $tmFE, fe cluster(tehsiln)
eststo EV1_cas6_est1
test $events1_a

//save F-Test p-value
local pval = round(`r(p)',0.001)
texdoc init "$tex/parallel_cas_p.tex", replace force
tex 0`pval'
texdoc close

//Plot event-study coefficents and output Figure 7b from main text
coefplot (EV1_cas6_est1, offset(0) recast(line) lwidth(*2) ciopts(recast(rline) lp(dash))), keep($events1 my10)  rescale(my10 = 0) order($events1_a my10 $events1_b) vertical xline(10) yline(0) ytitle("") xtitle("") xlabels(, labsize(medium)) ylabels(,angle(0) labsize(medium))
gr export "$figures/EV1_cas6.pdf", replace


/*
Re-run event-study regressions with normalized variables. Results 
presented in supplement.
*/
clear all

set scheme s1mono

use "$data/incFinalMonthlyTehsil"

label variable totCas_prop "Casualties"
label variable incidents_prop "Attacks"
label variable trtXnwa "treat\(\cdot\)nwa"
label variable my10 "0"

drop if dist=="swa"

xtset tehsiln monyr

xtreg incidents_prop $events1 $tmFE, fe cluster(tehsiln)
eststo EV1_inc6_est1
test $events1_a
local pval = round(`r(p)',0.001)
texdoc init "$tex/parallel_inc_p_prop.tex", replace force
tex 0`pval'
texdoc close

//Plot event-study coefficents and output Figure 1 of the supplement
coefplot (EV1_inc6_est1, offset(0) recast(line) lwidth(*2) ciopts(recast(rline) lp(dash))), keep($events1 my10)  rescale(my10 = 0) order($events1_a my10 $events1_b) vertical xline(10) yline(0) ytitle("") xtitle("") xlabels(, labsize(medium)) ylabels(,angle(0) labsize(medium))
gr export "$figures/EV1_inc6_prop.pdf", replace


xtreg totCas_prop $events1 $tmFE, fe cluster(tehsiln)
eststo EV1_cas6_est1
test $events1_a
local pval = round(`r(p)',0.001)
texdoc init "$tex/parallel_cas_p_prop.tex", replace force
tex 0`pval'
texdoc close

//Plot event-study coefficents and output Figure 2 of the supplement
coefplot (EV1_cas6_est1, offset(0) recast(line) lwidth(*2) ciopts(recast(rline) lp(dash))), keep($events1 my10)  rescale(my10 = 0) order($events1_a my10 $events1_b) vertical xline(10) yline(0) ytitle("") xtitle("") xlabels(, labsize(medium)) ylabels(,angle(0) labsize(medium))
gr export "$figures/EV1_cas6_prop.pdf", replace
